﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace AvvaMobileNHibernateHelperKit.Controls
{
    public partial class NewsListItem : UserControl
    {
        public NewsListItem(string _title, string _text)
        {
            InitializeComponent();
            title = _title;
            text = _text;
        }

        string title, text;

        bool openBrowser = true;

        public bool AllowOpenBrowser
        {
            get
            {
                return openBrowser;
            }
            set
            {
                openBrowser = value;
            }
        }

        private void NewsListItem_Load(object sender, EventArgs e)
        {
            this.Height = 100;
            this.lnkTitle.Text = title;
            this.lblText.Text = text;
            this.Height = lnkTitle.Height + lblText.Height + 5;

            if(this.lblText.Width > this.lnkTitle.Width)
            {
                this.Width = this.lblText.Width + 10;
            }
            else
            {
                this.Width = this.lnkTitle.Width + 10;
            }
        }

        private void lblText_Click(object sender, EventArgs e)
        {
            //this.BorderStyle = BorderStyle.FixedSingle;
        }

        private void OpenBrowser(object sender, EventArgs e)
        {
            if(AllowOpenBrowser)
            {
                System.Diagnostics.Process.Start("http://www.dotnetishere.com/nhstudio/news/news.htm");
            }
        }
    }
}
